package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

//日报
@Getter
@Setter
public class Daily {

    public static final Integer STATE_NORMAl = 0 ;//不推荐
    public static final Integer STATE_HOT = 1 ;//推荐


    private Long id; // 主键id

    private String coverUrl; // 封面

    private String title; //标题

    private String subTitle;  // 副标题
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date creatTime; //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date releaseTime; //发布时间

    private Region place; //地区id

    private Integer state; // 状态

    //日报内容
    private DailyContent content;

    public String getStateDisplay(){
        if (state == STATE_NORMAl){
            return "普通日报";
        }else if (state == STATE_HOT){
            return "头条日报";
        }else {
            return "";
        }
    }
    //编辑框的回显
    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        if (place!=null) {
            map.put("placeId", place.getId());
            map.put("placeName", place.getName());
        }

        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

}